export type IClazz<T> = new (...param: any[]) => T;

export default class Instance {
    public static get<T>(clazz: IClazz<T>, ...param: any[]): T {
        if (clazz['__Instance__'] == null) {
            clazz['__Instance__'] = new clazz(...param);
        }
        return clazz['__Instance__'];
    }

    public static del<T>(clazz: IClazz<T>): void {
        if (clazz['__Instance__'] != null) {
            delete clazz['__Instance__'];
            clazz['__Instance__'] = null;
        }
    }
}
